//
//  IHTestViewController.swift
//  InternetHospital
//
//  Created by Shelby on 2019/1/11.
//  Copyright © 2019 ZhuJiangChilink. All rights reserved.
//

import UIKit
import SnapKit
import RxSwift
import RxCocoa
class IHTestViewController: IHBaseViewController {
    var label = UILabel()
    let bag = DisposeBag()
let viewModel = IHTestVM()
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        setupLabel()
        test()
    }
    
    private func setupLabel() -> Void {
        view.addSubview(label)
        label.textColor = .black
        label.frame = CGRect(x: 0, y: 400, width: 100, height: 30)
        label.backgroundColor = .green
        viewModel.obs.subscribe(
            onNext: { [weak self] root in
                print(root.msg)
                self?.label.text = root.msg
            }
        ).disposed(by: bag)
    }
    
    private func test() -> Void {
        let btn = UIButton()
        view.addSubview(btn)
        _ = btn.rx.tap.subscribe { [weak self] e  in
            self?.viewModel.getData { (err, root) in
//                print("root = \(root)")
            }
        }
        btn.frame = CGRect(x: 0, y: 200, width: 100, height: 100)
        btn.backgroundColor = .yellow
    }
    
    
    
    

}
